package com.finger.orderservice.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.finger.modelservice.enums.OrderStatusEnum;
import com.finger.modelservice.model.order.OrderInfo;
import com.finger.modelservice.result.Result;
import com.finger.modelservice.vo.order.OrderQueryVo;
import com.finger.orderservice.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RefreshScope
@RequestMapping("admin/order/orderInfo")
@RestController
public class AdminOrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;


    // 后天管理员查找全部订单
    @PostMapping("findOrdersPage/{current}/{limit}")
    public Result findOrdersPage(@RequestBody OrderQueryVo orderQueryVo,
                                 @PathVariable Integer current,
                                 @PathVariable Integer limit){

        Page<OrderInfo> page = new Page<>(current, limit);

        return Result.ok(orderInfoService.findOrderInfoPage(page,orderQueryVo));
    }

    // 后台，获取订单状态集合
    @GetMapping("getStatusList")
    public Result getStatusList(){

        return Result.ok(OrderStatusEnum.getStatusList());

    }

    @GetMapping("getOrderInfoById/{orderId}")
    public Result getUserInfoById(@PathVariable String orderId){

        OrderInfo orderInfo = orderInfoService.findOrderInfo(orderId);

        return Result.ok(orderInfo);
    }

}
